package Controllers;

import Bean.BeanPlace;
import Bean.BeanTeacher;
import Impl.PlaceServiceImpl;
import Impl.TeacherServiceImpl;
import com.alibaba.fastjson.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

@Controller
public class PlaceModifyController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    PlaceServiceImpl placeService;
	 @RequestMapping(value = "/PlaceModify", method = RequestMethod.POST)
		@ResponseBody
		public JSONObject userRegister(HttpServletRequest request,@RequestBody JSONObject in) throws Exception {
		 	ApplicationContext applicationContext=(ApplicationContext)request.getSession().getServletContext().getAttribute("ctx");
	        placeService=(PlaceServiceImpl) applicationContext.getBean("PlaceServiceImpl");
			JSONObject obj = new JSONObject();
			BeanPlace place = new BeanPlace();
			place.setPlace_id(Integer.parseInt(in.getString("placeid")));
			place.setPlace_name(in.getString("placename"));
			place.setPlace_photo(in.getString("placephoto"));
			place.setPlace_introduction(in.getString("placeintroduction"));
			placeService.placeupdate(place.getPlace_id(),place.getPlace_name(), place.getPlace_photo(), place.getPlace_introduction());
			obj.put("status", "OK");
			return obj;
		}
}
